<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('物联网卡充值记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" id="deviceId" name="deviceId" th:value="${deviceId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>设备号：</label>
                                <input type="text" id="deviceCode" name="deviceCode" />
                            </li>
                            <li>
                                <label>充值卡号：</label>
                                <input type="text" name="rechargeNo"/>
                            </li>
                            <li>
                                <label>充值人：</label>
                                <input type="text" name="rechargeUser"/>
                            </li>
                            <li class="select-time">
                                <label>充值时间：</label>
                                <input type="text" class="time-input"   placeholder="开始时间" name="params[beginCreateTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input"  placeholder="结束时间" name="params[endCreateTime]"/>
                            </li>
                            <li class="select-time">
                                <label>到期时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginExpireTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endExpireTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="biz:renew:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="biz:renew:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="biz:renew:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                <a id="closeId" class="btn btn-warning" onclick="closeItem()">
                    <i class="fa fa-reply-all"></i> 返回
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('biz:renew:edit')}]];
        var removeFlag = [[${@permission.hasPermi('biz:renew:remove')}]];
        var prefix = ctx + "biz/renew";

        $(function() {
            var deviceId = $("#deviceId").val();
            console.log("deviceId:",deviceId);
            if(null == deviceId || 0 == deviceId){
                $("#closeId").hide();
            }
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add?deviceId="+deviceId,
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                sortName: "id",
                sortOrder: "desc",
                modalName: "物联网卡充值记录",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'tenantId',
                    title: '租户标识',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 15, 'open');
                    },
                    visible: false
                },
                {
                    field: 'deviceId',
                    title: '设备ID',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    },
                    visible: false
                },
                {
                    field: 'deviceCode',
                    title: '设备号',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 20, 'open');
                    }
                },
                {
                    field: 'rechargeNo',
                    title: '充值卡号',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 20, 'open');
                    }
                },
                {
                    field: 'rechargeUser',
                    title: '充值人',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'createTime',
                    title: '充值时间',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'expireTime',
                    title: '到期时间',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'effectiveDuration',
                    title: '有效期限(年)',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'remark',
                    title: '备注',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a style="margin-top: 3px;" class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.id + '\')"><i class="fa fa-info"></i> 详情</a> ');
                        actions.push('<a style="margin-top: 3px;" class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i> 删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function detail(id) {
            var url = prefix + '/detail/' + id + "?time=" + (new Date()).getTime();
            $.modal.openTab("物联网卡充值记录详情", url);
        }
    </script>
</body>
</html>